#include "common/pch.h"
#include "map/battlegroundmap.h"

BattleGroundMap::BattleGroundMap(unsigned int id, time_t expiry, unsigned int InstanceId)
    : Map(id, expiry, InstanceId)
{
    // lets initialize visibility distance for BG/Arenas
    BattleGroundMap::InitVisibilityDistance();
}

BattleGroundMap::~BattleGroundMap()
{
}

void BattleGroundMap::Update(const unsigned int& diff)
{
    Map::Update(diff);
#if 0
    GetBG()->Update(diff);
#endif
}

BattleGroundPersistentState* BattleGroundMap::GetPersistanceState() const
{
    return (BattleGroundPersistentState*)Map::GetPersistentState();
}


void BattleGroundMap::InitVisibilityDistance()
{
#if 0
    // init visibility distance for BG/Arenas
    m_VisibleDistance = World::GetMaxVisibleDistanceInBGArenas();
#endif
}

bool BattleGroundMap::CanEnter(battle::object::Player* player)
{
    if (!Map::CanEnter(player))
    {
        return false;
    }

#if 0
    if (player->GetBattleGroundId() != GetInstanceId())
    {
        return false;
    }
#endif

    // player number limit is checked in bgmgr, no need to do it here
    return true;
}

bool BattleGroundMap::Add(battle::object::Player* player)
{
    if (!CanEnter(player))
    {
        return false;
    }

    // reset instance validity, battleground maps do not homebind
#if 0
    player->m_InstanceValid = true;
#endif

    return Map::Add(player);
}

void BattleGroundMap::Remove(battle::object::Player* player, bool remove)
{
#if 0
    DETAIL_LOG("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName());
#endif
    Map::Remove(player, remove);
}

void BattleGroundMap::SetUnload()
{
    m_unloadTimer = MIN_UNLOAD_DELAY;
}

void BattleGroundMap::UnloadAll(bool pForce)
{
#if 0
    TeleportAllPlayersTo(TELEPORT_LOCATION_BG_ENTRY_POINT);
#endif
    Map::UnloadAll(pForce);
}